//
//  UndistributeCell.m
//  ZHZtest
//
//  Created by 李彦宏 on 2018/1/13.
//  Copyright © 2018年 LYH. All rights reserved.
//未分配cell

#import "UndistributeCell.h"


@interface UndistributeCell()<UIGestureRecognizerDelegate>
@end
@implementation UndistributeCell

//类方法快速创建cell
+(instancetype)cellwithTableview:(UITableView *)tableview{
    
    // 1.创建cell
    static NSString *ID = @"cell";
    UndistributeCell *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UndistributeCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return  cell;
    
}
/**
 *  cell的初始化方法，一个cell只会调用一次
 *  一般在这里添加所有可能显示的子控件，以及子控件的一次性设置
 */
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //添加UI控件
        [self setupUI];
    }
    return self;
}
-(void)setupUI
{
    //学员label
    UILabel *lb1=[[UILabel alloc]init];
    lb1.text=@"张三李四";
    lb1.font=[UIFont systemFontOfSize:14];
    lb1.textAlignment=NSTextAlignmentCenter;
    self.lb1=lb1;
    [self.contentView addSubview:lb1];
    //研究生label选择研究生
    UILabel *lb2=[[UILabel alloc]init];
    lb2.textAlignment=NSTextAlignmentCenter;
    lb2.textColor=XGColor;
    lb2.font=[UIFont systemFontOfSize:14];
    lb2.userInteractionEnabled=YES;
    self.lb2=lb2;
    [self.contentView addSubview:lb2];
    //添加手势
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImgAction:)];
    tap.numberOfTouchesRequired = 1; //手指数
    tap.numberOfTapsRequired = 1; //tap次数
    tap.delegate= self;
    [self.lb2 addGestureRecognizer:tap];


    
    //专业label
    UILabel *lb3=[[UILabel alloc]init];
    lb3.text=@"张三李四张三李四张三李四";
    lb3.font=[UIFont systemFontOfSize:14];
    lb3.textAlignment=NSTextAlignmentCenter;
    lb3.numberOfLines=0;
    self.lb3=lb3;
    [self.contentView addSubview:lb3];
    //设置fram
    
    [lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ScreenWidth/2-50, 30));
        make.top.equalTo(self.contentView).offset(5);
        make.bottom.equalTo(self.contentView).offset(5);
        make.right.equalTo(lb2.mas_left).offset(5);
        
        
    }];
    [lb2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lb1);
        make.centerX.equalTo(self.contentView);
        make.size.with.mas_equalTo(100);
    }];
    [lb3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(0);
        make.bottom.equalTo(self.contentView).offset(0);
        make.size.with.mas_equalTo(ScreenWidth/2-50);
        make.left.equalTo(lb2.mas_right).offset(5);
    }];
}
-(void)setSDmodel:(SDUserModel *)SDmodel{
    
    _SDmodel=SDmodel;
    self.lb1.text=_SDmodel.name;
    self.lb2.text=@"选择研究生";
    self.lb3.text=_SDmodel.college;
}
//手势响应
- (void)tapImgAction:(UIGestureRecognizer *)gestureRecognizer
{
    if(self.DisChooseBlock){
        self.DisChooseBlock();
    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
